<?php
namespace app\admin\model;

use think\Model;
                    

class ActiveCases extends Model
{
    public function getAll($where){
        $rs = ActiveCases::where($where)

            ->paginate(5);
                    
        return $rs;
                    
    }

    public function indexGetAll($where){
        $rs = ActiveCases::where($where)

            ->select();

        return $rs;

    }
                    
    public function getOne($where){
                    
        $rs = ActiveCases::where($where)
                    
        ->find();
                    
        return $rs;
                    
    }
                    
    public function add($data){
                    
        $rs = ActiveCases::data($data)
                    
        ->save();
                    
        return $rs;
                    
    }
                    
    public function edit($where,$data){
                    
        $rs = ActiveCases::where($where)
                    
        ->update($data);
                    
        return $rs;
                    
    }
                    
    public function del($where){
                    
        $rs = ActiveCases::where($where)
                    
        ->delete();
                    
        return $rs;
                    
    }

    public function detailJoin($where){
        $rs = ActiveCases::alias('ac')

            ->where('ac.id','=',$where['id'])

            ->join('active_cases_type act','act.id = ac.type','LEFT')

            ->field('ac.*,act.name as act_name,act.id as act_id')

            ->find();

        return $rs;
    }


}
                    
